package com.koron.order.cockpitStats.business.bean.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName DefectStatsGatherVo
 * @description 缺陷统计汇总Vo
 * @Author zhouj
 * @Date 2022/5/24 14:59
 */
@Data
public class DefectStatsGatherVo {

    @ApiModelProperty("累计未归档")
    private int notArchived;

    @ApiModelProperty("各组织缺陷分类统计数量")
    private List<DefectStatsVo> defectStatsVoList;

    public List<DefectStatsVo> getDefectStatsVoList() {

        if (CollectionUtils.isEmpty(defectStatsVoList)) {
            return new ArrayList<>();
        }

        return defectStatsVoList;
    }

    public int getNotArchived() {
        if (notArchived>0){
            return notArchived;
        }
        List<DefectStatsVo> defectStatsVoList = getDefectStatsVoList();

        if (CollectionUtils.isEmpty(defectStatsVoList)) {
            return notArchived;
        }

        return defectStatsVoList.stream().mapToInt(DefectStatsVo::getNotFinish).sum();
    }
}
